package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dto.Score;

import schoolDAO.ScoreDAO;

public class RegisterScoreServlet extends HttpServlet {

	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req,resp);
	}
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		    String mId = req.getParameter("mId");
		    String pId = req.getParameter("pId");
		    int grade = Integer.parseInt(req.getParameter("grade"));
						
			ScoreDAO sd = new ScoreDAO();
			Score s = new Score();
			s.setmId(mId);
			s.setpId(pId);
			s.setgrade(grade);

			int flag = sd.insert(s);
			if(flag==1){
	
				resp.sendRedirect(req.getContextPath()+"/admin/allScore.jsp");
			}else{
				resp.sendRedirect(req.getContextPath()+"/error.html");
			}
	
}
}